<?php

namespace app\common\model\Hotel;

use app\common\model\Business\Business;
use think\Model;

class Order extends Model
{
    // 表名
    protected $name = 'hotel_order';
    // 忽略数据表不存在的字段
    protected $field = true;
    // 设置返回的结果类型
    protected $resultSetType = 'collection';
    // 追加属性
    protected $append = [
        'comdate'
    ];
    public function business()
    {
        return $this->belongsTo(Business::class,'busid','id',[],'left')->setEagerlyType(0);
    }
    public function getComdateAttr($value,$data)
    {
        if(!isset($data['comtime']))return;
        return date('Y-m-d H:i:s',$data['comtime']);
    }
}
